///////////////////////////////////////////////////////////////////////////////
//
//
//
//
///////////////////////////////////////////////////////////////////////////////

package model.service
{
    import flash.net.URLRequest;

    import org.kolonitsky.alexey.debug.DebugWrapper;

    import org.kolonitsky.alexey.net.ElfinSerivce;

    /**
     * Complete event dispatched when operation is complete.
     */
    [Event(name="complete", type="flash.events.Event")]

    /**
     *  Service for retrieve authenticity token. For load authenticity
     *  token from on on available sources. Call getAuthToken method for
     *  detect availabel server and get token.
     */
    public class AuthService extends ElfinSerivce
    {
        //---------------------------------------------------------------------
        //  Properties
        //---------------------------------------------------------------------

        public function get authToken():String
        {
            if (lastData && "authenticity_token" in lastData)
                return lastData.authenticity_token;

            DebugWrapper.trace("ERROR: AuthService.authToken. Login response is empty.");
            return "";
        }


        //---------------------------------------------------------------------
        //  Methods
        //---------------------------------------------------------------------

        public function AuthService()
        {
            super();
        }

        /**
         *
         * @param sources
         */
        public function getAuthToken():void
        {
            load(Config.TOKEN_GET);
        }



    }
}
